<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        img {
            width: 300px;
        }
    </style>
</head>
<body>
    <img src ="../images/ldh.jpg">
    <div>上午好</div>
    <script>
        //1.获取元素
        var img = document.querySelector('img');
        var div = document.querySelector('div');
        //得到当前小时数
        var date = new Date();
        var h = date.getHours();
        //3.判断小时数改变图片和文字信息
        if(h<12){
            img.src='../images/ldh.jpg';
            div.innerHTML = '亲，今天学习时间过少要加油哦！';
        }else if(h<18){
            img.src = '../images/zxy.jpg';
            div.innerHTML = '亲，要继续加油哦！';
        }else{
            img.src = '../images/sleep.jpg';
            div.innerHTML = '充足睡眠是有必要的，这样才能更好努力奋斗！';
        }
    </script>
</body>
</html>